package com.cby.user.test3D;


import javax.swing.event.ListDataEvent;
import java.io.IOException;
import java.util.*;

/*
**  Create by: 王孙康宏
    Date:2021-10-24
    Time:21:54
*/
public class SingleApplication {
    static String path = "D:\\IDEA_PaidVersion\\cby\\back\\cby_user_7001\\src\\main\\java\\com\\cby\\user\\test3D\\data\\instance.txt";
    public static void main(String[] args) throws Exception {
        myMethod(args);
//        zhuMethod(args);
    }
    public static void myMethod(String[] args) throws Exception {
        long startTime = System.currentTimeMillis();
        DataUtil dataUtil = new DataUtil(1f);
        // 给定20s计算时间
        SinglePacking model = new SinglePacking(dataUtil.read(path),200L*1000L);
        Solution solution = model.solve();
        System.out.println("一共有"+solution.getTotalBoxNum()+"个箱子，装载了"+solution.getPlaceBoxes().length+"个");
        System.out.println("容器利用率为："+solution.getPackRate());
        long endTime = System.currentTimeMillis();
        System.out.println("用时："+(endTime-startTime)+"ms");
        // 转化为cubeList
        PlaceBox[] placeBoxes = solution.getPlaceBoxes();
        for (int i = 0; i < placeBoxes.length; i++) {
            PlaceBox placeBox = placeBoxes[i];
            // 坐标
            double x = placeBox.getX()+placeBox.getL()/2.0;
            double y = placeBox.getY()+placeBox.getW()/2.0;
            double z = placeBox.getZ()+placeBox.getH()/2.0;
            // 长宽高
            double l = placeBox.getL();
            double w = placeBox.getW();
            double h = placeBox.getH();
            Cube cube = new Cube(x,y,z,l,w,h);
            System.out.println(cube);
        }
    }
}
